/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : led.c
  * @brief          : LED control module implementation
  ******************************************************************************
  */
/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#include "led.h"

/* Private variables ---------------------------------------------------------*/
static uint8_t led_state = 0; /* LED当前状态，0表示关闭，1表示打开 */

/* Private function prototypes -----------------------------------------------*/

/* Exported functions --------------------------------------------------------*/

/**
  * @brief  Initialize the LED
  * @retval None
  */
void LED_Init(void)
{
  /* LED已经在main.c的MX_GPIO_Init中初始化，这里可以添加额外的初始化代码 */
  LED_Off(); /* 初始状态设置为关闭 */
}

/**
  * @brief  Toggle the LED state
  * @retval None
  */
void LED_Toggle(void)
{
  HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
  led_state = !led_state;
}

/**
  * @brief  Turn on the LED
  * @retval None
  */
void LED_On(void)
{
  HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, LED_ON);
  led_state = 1;
}

/**
  * @brief  Turn off the LED
  * @retval None
  */
void LED_Off(void)
{
  HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, LED_OFF);
  led_state = 0;
}

/**
  * @brief  Blink the LED with specified delay
  * @param  delay_ms: Delay in milliseconds between LED state changes
  * @retval None
  */
void LED_Blink(uint32_t delay_ms)
{
  LED_Toggle();
  HAL_Delay(delay_ms);
  LED_Toggle();
  HAL_Delay(delay_ms);
}

/* USER CODE BEGIN 1 */

/* USER CODE END 1 */